package com.ado.abyss.core.web.controller;

import com.ado.abyss.core.constants.LogEnum;
import com.ado.abyss.core.params.http.HttpResult;
import com.ado.abyss.core.params.page.PageRequest;
import com.ado.abyss.core.web.controller.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ado.abyss.core.service.SysLogService;

import lombok.extern.slf4j.Slf4j;

/**
 * 
 * @author adonais
 * @date 2020/06/08
 * @description 日志控制器
 *
 */
@Slf4j
@RestController
@RequestMapping(value = "/api/log")
public class LogController extends BaseController {
	
	@Autowired
	@Qualifier(value = "sysLogService")
	private SysLogService sysLogService;

	@PreAuthorize("hasAuthority('sys:log:view')")
	@PostMapping(value="/findPage")
	public HttpResult findPage(@RequestBody PageRequest pageRequest) {
		setLog(LogEnum.LOG_MODULE.getModuleName() , "日志记录分页查询接口，入参:"+pageRequest.toString());
		return HttpResult.ok(sysLogService.findPage(pageRequest));
	}

}
